package com.aaa.java04;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/5 16:37
 * @description：火车票售票员
 * @modified By：
 * @version: 1.0
 */
public class TicketSaler {
    String  name;
    //属于类，所有的对象共享
    //final 修饰变量，变量变常量，不可修改，并且必须赋初始值
    static    int tickets;

    public TicketSaler() {
    }



    public TicketSaler(String name) {
        this.name = name;
    }


    public  void saleTicket(){
        tickets--;
        System.out.println("售票员"+name+"卖出一张火车票");
    }

    public static void main(String[] args) {
        System.out.println("买票之前的票数："+100);
        TicketSaler ticketSaler1 = new TicketSaler("张三");
        TicketSaler ticketSaler2 = new TicketSaler("李四");
        ticketSaler1.saleTicket();
        ticketSaler2.saleTicket();
        System.out.println("买票之后的票数："+ TicketSaler.tickets);
    }
}
